// 导入redux (不能使用ES6 的方式导入)
import { createStore } from 'redux';
// redux 的三个核心

// 1. 定义初始化值
const initialState = {
    chartData: {
        type: 'chartData',
        data: []
    },  chartDataMySelf:{
        type: 'chartDataMySelf',
        data: []
    }, chartOperationComparison: {
        type: 'chartOperationComparison',
        data: []
    }
};
// reducer
// 2.
function reducer(state = initialState, action) {
  

  
    if(action.type === "chartData") {
        state.chartData = action
    } else if(action.type === "chartDataMySelf") {
        state.chartDataMySelf = action
    } else if(action.type === "chartOperationComparison") {
        state.chartOperationComparison = action
    }
  return state;
}

// store (创建的时候需要传入一个reducer)
// 3.
const store = createStore(reducer);


// 5.订阅store的修改
store.subscribe(() => {
  
});

// actions
// 4. 要派发的数据
const action1 = { type: "INCREMENT" };


export default store;
